﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CYPlayerScreens
{
	/// <summary>
	/// Interaction logic for CompactMode.xaml
	/// </summary>
	public partial class CompactMode : UserControl
	{
		private bool moving = false;
		
		VisualStateGroup tempvsg = new VisualStateGroup(); 
		VisualState tempvs = new VisualState();
		
		//[0] - PL, [1] - play/pause, [2] - stop
		public bool[] btns = {false,false,false};
		public CompactMode()
		{
			this.InitializeComponent();
			//tempvs.Name="temp";		
		}

		private void butPL_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			btns[0]=!btns[0];
			
			/*if(btns[0])
				songsLbComponent.Opacity=0;
			else
				songsLbComponent.Opacity=100;*/
			if(btns[0])
			{
				//for(int i=1;i<1010;i++)
				//	songsLbComponent.Opacity+=0.1;
				//songsLbComponent.HorizontalAlignment=System.Windows.HorizontalAlignment.Left;
								
				VisualStateManager.GoToState(this,"enablePL",true);
			}
			else
			{
				/*tempvsg = (VisualStateGroup)VisualStateManager.GetVisualStateGroups(this)[0];
				
				Thickness tempth = new Thickness();
				tempth.Top = songsLbComponent.Margin.Top;
				tempth.Right = songsLbComponent.Margin.Right;
				
				IList<VisualStateGroup> tempgr = (IList<VisualStateGroup>)VisualStateManager.GetVisualStateGroups(this);
				tempvs = (VisualState)tempvsg.States[1];
				tempvs.SetValue(Grid.MarginProperty,tempth);
				tempgr[0].States[1]=tempvs;
				
				VisualStateManager cvsm = new VisualStateManager();
				cvsm.SetValue(VisualStateManager.VisualStateGroupsProperty,tempgr);
				VisualStateManager.SetCustomVisualStateManager(this,cvsm);*/
				VisualStateManager.GoToState(this,"_default",true);
			}
			//	for(int i=1;i<1010;i++)
			//		songsLbComponent.Opacity-=0.1;
				
		}

		private void btnPlay_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			btns[1]=!btns[1];
			if(btns[1])
				VisualStateManager.GoToState(this,"pressPlay",true);
			else
				VisualStateManager.GoToState(this,"defaultPlay",true);
		}

		private void btnStop_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			if(btns[1])
				VisualStateManager.GoToState(this,"defaultPlay",true);
		}
		public double offX;
		public double offY;
		private void songsLbComponent_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
			moving = true;
			Point off = e.GetPosition(playListControl);
			offX = off.X;
			offY = off.Y;
		}

		private void songsLbComponent_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
			moving=false;
		}

		/*private void songsLbComponent_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
		{
			if(moving==true)
			{
				Grid parent = (Grid)this.songsLbComponent.Parent;
				Point p = e.GetPosition(parent);
				double x = p.X;// - offX;
				double y = p.Y;// - offY;
				Thickness mx = new Thickness();
				mx.Top = y-offY;
				mx.Right =-x+offX;//+songsLbComponent.Width;
				//mx.Bottom =- songsLbComponent.Height;
				//mx.Left = x;//-offX;
				
				Thickness my = new Thickness();
				my.Top = y-offY;
				
				songsLbComponent.Margin = mx;
				//this.songsLbComponent.SetValue(Grid.MarginProperty,mx);
				//this.songsLbComponent.SetValue(Grid.MarginProperty,my);
			}
		}*/

	}
}